<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">

    <div class="modal-header">
        <h4 class="modal-title" id="myDBFileLabel">Create or edit a DB File</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                (click)="clear()">&times;</button>
    </div>
    <div class="modal-body">
        <jhi-alert-error></jhi-alert-error>
        <div class="form-group" [hidden]="!dBFile.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id"
                   [(ngModel)]="dBFile.id" readonly />
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_fileName">File Name</label>
            <input type="text" class="form-control" name="fileName" id="field_fileName"
                [(ngModel)]="dBFile.fileName" />
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_fileType">File Type</label>
            <input type="text" class="form-control" name="fileType" id="field_fileType"
                [(ngModel)]="dBFile.fileType" />
        </div>
        <div class="form-group">
            <label class="form-control-label" for="field_data">Data</label>
            <div>
                <div *ngIf="dBFile.data" class="form-text text-danger clearfix">
                    <a class="pull-left" (click)="openFile(dBFile.dataContentType, dBFile.data)">open</a><br>
                    <span class="pull-left">{{dBFile.dataContentType}}, {{byteSize(dBFile.data)}}</span>
                    <button type="button" (click)="dBFile.data=null;dBFile.dataContentType=null;"
                            class="btn btn-secondary btn-xs pull-right">
                        <span class="fa fa-times"></span>
                    </button>
                </div>
                <input type="file" id="file_data" (change)="setFileData($event, dBFile, 'data', false)"/>
            </div>
            <input type="hidden" class="form-control" name="data" id="field_data"
                [(ngModel)]="dBFile.data" />
            <input type="hidden" class="form-control" name="dataContentType" id="field_dataContentType"
                [(ngModel)]="dBFile.dataContentType" />
        </div>

    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="clear()">
            <span class="fa fa-ban"></span>&nbsp;<span>Cancel</span>
        </button>
        <button type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
            <span class="fa fa-save"></span>&nbsp;<span>Save</span>
        </button>
    </div>
</form>
